#include <iostream>
#include <filesystem>

namespace fs = std::filesystem;

int main() {
    printf("cwd: %s\n", fs::current_path().string().c_str());

    fs::path exampleFile = "D:\\_workspace\\png\\1.png";
    printf("string: %s\n", exampleFile.string().c_str());
    printf("generic_string: %s\n", exampleFile.generic_string().c_str());
    printf("root_name: %s\n", exampleFile.root_name().string().c_str());
    printf("root_directory: %s\n", exampleFile.root_directory().string().c_str());
    printf("root_path: %s\n", exampleFile.root_path().string().c_str());
    printf("relative_path: %s\n", exampleFile.relative_path().string().c_str());
    printf("parent_path: %s\n", exampleFile.parent_path().string().c_str());
    printf("filename: %s\n", exampleFile.filename().string().c_str());
    printf("stem: %s\n", exampleFile.stem().string().c_str());
    printf("extension: %s\n", exampleFile.extension().string().c_str());

    fs::path srcDir = "D:\\_workspace\\png";
    fs::path dstDir = "D:\\_workspace\\jpg";
    if (!fs::exists(srcDir)) {
        return -1;
    }
    if (!fs::exists(dstDir)) {
        fs::create_directory(dstDir);
    }
    for (const fs::directory_entry &entry: fs::directory_iterator(srcDir)) {
        if (entry.is_regular_file() and entry.path().extension() == ".png") {
            printf("%s\n", entry.path().string().c_str());
            fs::path dstFileName = entry.path().filename().replace_extension("jpg");
            fs::path dst = dstDir / dstFileName;
            printf("%s\n", dst.string().c_str());
        }
    }
}